/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 34255
 * Date: 2024-06-15
 * Time: 19:38
 */
public class Test {
    public int[] merge (int[] num1, int m, int[] num2, int n) {
        int pf = m + n - 1;
        int pf1 = m - 1;
        int pf2 = n - 1;

        while(pf1 >= 0 || pf2 >= 0){
            if(num1[pf1] >= num2[pf2]){
                num1[pf--] = num1[pf1--];
            }else{
                num1[pf--] = num2[pf2--];
            }
        }
        while(pf2 >= 0){
            num1[pf--] = num2[pf2--];
        }
        return num1;
    }
    public static void main(String[] args) {

    }
}
